package prj.common.service;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.stereotype.Service;

@Service
public class Mailer {
	private MailSender springMailer;
	private SimpleMailMessage mailMessage;
	
	@Autowired
	public void setSpringMailer(MailSender springMailer) {
		this.springMailer = springMailer;
	}
	@Autowired
	public void setMailMessage(SimpleMailMessage mailMessage) {
		this.mailMessage = mailMessage;
	}
	public void sendMail(String replyTo, String subject, String msg){
		mailMessage.setFrom(replyTo);
		mailMessage.setReplyTo(replyTo);
		mailMessage.setSubject(subject);
		mailMessage.setText(msg);
		mailMessage.setSentDate(new Date());
		springMailer.send(mailMessage);
	}
}
